clear
program drop _all
cd C:\Users\dpage\Downloads\

use Table1Figure1data, replace 


*JCR_table1
reg fairoutcome2014 i.UnpackedReligion ageconf educ hhincome Women evacuate baranpdc corruptdum2 corruptdum3 corruptdum4 presdum1 presdum2 [pw=wtfinal]

reg imptrustnation2014 i.UnpackedReligion ageconf educ hhincome Women evacuate baranpdc corruptdum2 corruptdum3 corruptdum4 presdum1 presdum2  [pw=wtfinal]

reg natgovtrust i.UnpackedReligion ageconf educ hhincome Women evacuate baranpdc corruptdum2 corruptdum3 corruptdum4 presdum1 presdum2  [pw=wtfinal]

reg provgovtrust i.UnpackedReligion ageconf educ hhincome Women evacuate baranpdc corruptdum2 corruptdum3 corruptdum4 presdum1 presdum2  [pw=wtfinal]


save JCR_graphsdataset, replace


*****************************************************************************************
*****************************************************************************************

collapse (mean) MEANSmean=fairoutcome2014 (sem) MEANSse=fairoutcome2014, by(UnpackedReligion)

gen MEANHi = MEANSmean + MEANSse*1.96
gen MEANLo = MEANSmean - MEANSse*1.96

#delimit ;
graph twoway (bar MEANSmean UnpackedReligion, color(black) barwidth(.5)) 
(rcap MEANHi MEANLo UnpackedReligion), 
 scheme(s1mono)
 ylabel(1(1)5)
ytitle("Mean(2014 Outcome is Fair)", size(small))
xlabel(0 "Other Islam" 1 "MILF" 2 "MNLF" 3 "Christian") 
title("2014 Agreement was Fair" , size(small))
note("Dependent variable: 1(Strongly Disagree)-5(Strongly Agree)")
ysize(2) xsize(2)
name(GPH1, replace) 
legend(off)
;
#delimit cr

*****************************************************************************************
*****************************************************************************************

clear
use JCR_graphsdataset, clear 

collapse (mean) MEANSmean=imptrustnation2014 (sem) MEANSse=imptrustnation2014, by(UnpackedReligion)

gen MEANHi = MEANSmean + MEANSse*1.96
gen MEANLo = MEANSmean - MEANSse*1.96

#delimit ;
graph twoway (bar MEANSmean UnpackedReligion, color(black) barwidth(.5)) 
(rcap MEANHi MEANLo UnpackedReligion), 
 scheme(s1mono)
 ylabel(1(1)5)
ytitle("Mean(2014 Outcome Improves Trust)", size(small))
xlabel(0 "Other Islam" 1 "MILF" 2 "MNLF" 3 "Christian") 
title("2014 Agreement Improves Government" , size(small))
note("Dependent variable: 1(Strongly Disagree)-5(Strongly Agree)")
ysize(2) xsize(2)
name(GPH2, replace) 
legend(off)
;
#delimit cr

*****************************************************************************************
*****************************************************************************************

clear
use JCR_graphsdataset, clear 

collapse (mean) MEANSmean=natgovtrust (sem) MEANSse=natgovtrust, by(UnpackedReligion)

gen MEANHi = MEANSmean + MEANSse*1.96
gen MEANLo = MEANSmean - MEANSse*1.96

#delimit ;
graph twoway (bar MEANSmean UnpackedReligion, color(black) barwidth(.5)) 
(rcap MEANHi MEANLo UnpackedReligion), 
 scheme(s1mono)
 ylabel(1(1)4)
ytitle("Mean(Trust in the Government)", size(small))
xlabel(0 "Other Islam" 1 "MILF" 2 "MNLF" 3 "Christian") 
title("Trust in the National Government" , size(small))
note("Dependent variable: 1(No trust at all) - 4(A lot of trust)")
ysize(2) xsize(2)
name(GPH3, replace) 
legend(off)
;
#delimit cr

*****************************************************************************************
*****************************************************************************************

clear
use JCR_graphsdataset, clear 

collapse (mean) MEANSmean=provgovtrust (sem) MEANSse=provgovtrust, by(UnpackedReligion)

gen MEANHi = MEANSmean + MEANSse*1.96
gen MEANLo = MEANSmean - MEANSse*1.96

#delimit ;
graph twoway (bar MEANSmean UnpackedReligion, color(black) barwidth(.5)) 
(rcap MEANHi MEANLo UnpackedReligion), 
 scheme(s1mono)
 ylabel(1(1)4)
ytitle("Mean(Trust in the Government)", size(small))
xlabel(0 "Other Islam" 1 "MILF" 2 "MNLF" 3 "Christian") 
title("Trust in the Provincial Government" , size(small))
note("Dependent variable: 1(No trust at all) - 4(A lot of trust)")
ysize(2) xsize(2)
name(GPH4, replace) 
legend(off)
;
#delimit cr



*Figure 1
*****************************************************************************************
*****************************************************************************************

#delimit ;
graph combine GPH1 GPH2 GPH3 GPH4, rows(2) scheme(s1mono) ysize(5.5) xsize(6)
title("Figure 1: Beliefs in Fairness and Governmental Trust regarding the BBL/CAB" "by Political-Religious Groups with 95 percent CIs", size(medsmall))
note("Data source:  Philippines Power-sharing Survey")
;
#delimit cr

************************************************************************************************************
************************************************************************************************************
************************************************************************************************************
************************************************************************************************************
clear

use Table3Figure2data, replace 

*Table 3

#delimit ; 
oprobit TrustNationalGov Islam  
MILF EthnicDiverseplusMILF NationalGovRedistribution BangsamoroAutonomy
[pw=wtfinal]
;
#delimit cr

#delimit ; 
oprobit TrustNationalGov Islam  
MILF EthnicDiverseplusMILF NationalGovRedistribution BangsamoroAutonomy
IslamMILF IslamEthnicDiverseplusMILF IslamNationalGovRedistribution IslamBangsamoroAutonomy  
[pw=wtfinal]
;
#delimit cr

#delimit ; 
oprobit TrustNationalGov Islam  
MILF EthnicDiverseplusMILF NationalGovRedistribution BangsamoroAutonomy
IslamMILF IslamEthnicDiverseplusMILF IslamNationalGovRedistribution IslamBangsamoroAutonomy 
ageconf educ hhincome Women evacuate baranpdc corruptdum2 corruptdum3 corruptdum4 presdum1 presdum2 
[pw=wtfinal]
;
#delimit cr

set more off

egen ED_mean = mean(educ)
egen Age_mean = mean(ageconf)
egen Inc_mean = mean(hhincome)

keep if _n==1
keep ED_mean Age_mean Inc_mean

		matrix def b = e(b)
		matrix def V = e(V)
		mat list b
		mat list V

set more off

	save JCRIVs.dta, replace
	
	*program drop JCRRegression
	
program define JCRRegression
		use JCRIVs.dta, clear

		drawnorm b1-b22, means(b) cov(V)
		
	
		#delimit ;
		gen pTrustMILKChristUnfair = b1*1 + 
		b2*1 + b3*0 + b4*0 + b5*0 + 
		b6*1*1 + b7*1*0 + b8*1*0 + b9*1*0 + 
		b10*Age_mean + b11*ED_mean + b12*8340 + b13*1 + b14*1 + b15*0 + b16*0 + b17*0 + b18*0 + b19*0 + b20*1
		;
        #delimit cr
		
		#delimit ;
		gen pTrustEthMILKChristUnfair = b1*1 + 
		b2*0 + b3*1 + b4*0 + b5*0 + 
		b6*1*0 + b7*1*1 + b8*1*0 + b9*1*0 + 
		b10*Age_mean + b11*ED_mean + b12*8340 + b13*1 + b14*1 + b15*0 + b16*0 + b17*0 + b18*0 + b19*0 + b20*1
		;
        #delimit cr
		
		#delimit ;
	    gen pTrustNatGovChristUnfair  = b1*1 + 
		b2*0 + b3*0 + b4*1 + b5*0 + 
		b6*1*0 + b7*1*0 + b8*1*1 + b9*1*0 + 
		b10*Age_mean + b11*ED_mean + b12*8340 + b13*1 + b14*1 + b15*0 + b16*0 + b17*0 + b18*0 + b19*0 + b20*1
		;
        #delimit cr
		
	    #delimit ;
		gen pTrustBandsamoroChristUnfair = b1*1 +
		b2*0 + b3*0 + b4*0 + b5*1 + 
		b6*1*0 + b7*1*0 + b8*1*0 + b9*1*1 + 
		b10*Age_mean + b11*ED_mean + b12*8340 + b13*1 + b14*1 + b15*0 + b16*0 + b17*0 + b18*0 + b19*0 + b20*1
	    ;
        #delimit cr
		
	    #delimit ;
		gen pTrustIOChristUnfair = b1*1 + 
		b2*0 + b3*0 + b4*0 + b5*0 + 
		b6*1*0 + b7*1*0 + b8*1*0 + b9*1*0 + 
		b10*Age_mean + b11*ED_mean + b12*8340 + b13*1 + b14*1 + b15*0 + b16*0 + b17*0 + b18*0 + b19*0 + b20*1
	    ;
        #delimit cr
		
		
		***************************************************************
		
		
		#delimit ;
		gen pTrustMILKChristFair = b1*0 + 
		b2*1 + b3*0 + b4*0 + b5*0 + 
		b6*0*1 + b7*0*0 + b8*0*0 + b9*0*0 + 
		b10*Age_mean + b11*ED_mean + b12*8340 + b13*1 + b14*1 + b15*0 + b16*0 + b17*0 + b18*0 + b19*0 + b20*1
		;
        #delimit cr
		
		#delimit ;
		gen pTrustEthMILKChristFair = b1*0 + 
		b2*0 + b3*1 + b4*0 + b5*0 + 
		b6*0*0 + b7*0*1 + b8*0*0 + b9*0*0 + 
		b10*Age_mean + b11*ED_mean + b12*8340 + b13*1 + b14*1 + b15*0 + b16*0 + b17*0 + b18*0 + b19*0 + b20*1
	    ;
        #delimit cr
		
		#delimit ;
	    gen pTrustNatGovChristFair  = b1*0 + 
		b2*0 + b3*0 + b4*1 + b5*0 + 
		b6*0*0 + b7*0*0 + b8*0*1 + b9*0*0 + 
		b10*Age_mean + b11*ED_mean + b12*8340 + b13*1 + b14*1 + b15*0 + b16*0 + b17*0 + b18*0 + b19*0 + b20*1
	    ;
        #delimit cr
		
		#delimit ;
		gen pTrustBandsamoroChristFair = b1*0 + 
		b2*0 + b3*0 + b4*0 + b5*1 + 
		b6*0*0 + b7*0*0 + b8*0*0 + b9*0*1 + 
		b10*Age_mean + b11*ED_mean + b12*8340 + b13*1 + b14*1 + b15*0 + b16*0 + b17*0 + b18*0 + b19*0 + b20*1
	    ;
        #delimit cr
		
		#delimit ;
		gen pTrustIOChristFair = b1*0 + 
		b2*0 + b3*0 + b4*0 + b5*0 + 
		b6*0*0 + b7*0*0 + b8*0*0 + b9*0*0 + 
		b10*Age_mean + b11*ED_mean + b12*8340 + b13*1 + b14*1 + b15*0 + b16*0 + b17*0 + b18*0 + b19*0 + b20*1
	    ;
        #delimit cr
		
		************************************
		************************************
		
		rename b21 a1
		rename b22 a2 
	
		gen TrustMILKChristUnfair = 1-normal(a2-pTrustMILKChristUnfair)
		gen TrustEthMILKChristUnfair = 1-normal(a2-pTrustEthMILKChristUnfair) 
	    gen TrustNatGovChristUnfair  = 1-normal(a2-pTrustNatGovChristUnfair)
		gen TrustBandsamoroChristUnfair = 1-normal(a2-pTrustBandsamoroChristUnfair)
		gen TrustIOChristUnfair = 1-normal(a2-pTrustIOChristUnfair)

		gen TrustMILKChristFair = 1-normal(a2-pTrustMILKChristFair)
		gen TrustEthMILKChristFair = 1- normal(a2-pTrustEthMILKChristFair)
	    gen TrustNatGovChristFair = 1-normal(a2-pTrustNatGovChristFair)
		gen TrustBandsamoroChristFair = 1-normal(a2-pTrustBandsamoroChristFair)
		gen TrustIOChristFair = 1-normal(a2-pTrustIOChristFair)
		
	append using JCR.dta
	save JCR.dta, replace
			
			end
							
			clear
			save JCR.dta, replace emptyok
	
			set more off
			*simulating
			simulate, reps(1000):  JCRRegression

			use JCR.dta, clear
			
set more off

#delimit ; 
collapse (mean)

TrustMILKChristUnfair TrustEthMILKChristUnfair TrustNatGovChristUnfair TrustBandsamoroChristUnfair TrustIOChristUnfair TrustMILKChristFair TrustEthMILKChristFair TrustNatGovChristFair TrustBandsamoroChristFair TrustIOChristFair 

(sd)

TrustMILKChristUnfair_sd=TrustMILKChristUnfair 
TrustEthMILKChristUnfair_sd= TrustEthMILKChristUnfair
TrustNatGovChristUnfair_sd= TrustNatGovChristUnfair
TrustBandsamoroChristUnfair_sd= TrustBandsamoroChristUnfair
TrustIOChristUnfair_sd= TrustIOChristUnfair

TrustMILKChristFair_sd= TrustMILKChristFair
TrustEthMILKChristFair_sd= TrustEthMILKChristFair
TrustNatGovChristFair_sd= TrustNatGovChristFair
TrustBandsamoroChristFair_sd= TrustBandsamoroChristFair
TrustIOChristFair_sd= TrustIOChristFair

;
#delimit cr 



gen TrustMILKChristUnfair_hi = TrustMILKChristUnfair + 1.96*TrustMILKChristUnfair_sd
gen TrustMILKChristUnfair_lo = TrustMILKChristUnfair - 1.96*TrustMILKChristUnfair_sd

gen TrustEthMILKChristUnfair_hi = TrustEthMILKChristUnfair + 1.96*TrustEthMILKChristUnfair_sd
gen TrustEthMILKChristUnfair_lo = TrustEthMILKChristUnfair - 1.96*TrustEthMILKChristUnfair_sd

gen TrustNatGovChristUnfair_hi = TrustNatGovChristUnfair + 1.96*TrustNatGovChristUnfair_sd
gen TrustNatGovChristUnfair_lo = TrustNatGovChristUnfair - 1.96*TrustNatGovChristUnfair_sd

gen TrustBandsamoroChristUnfair_hi = TrustBandsamoroChristUnfair + 1.96*TrustBandsamoroChristUnfair_sd
gen TrustBandsamoroChristUnfair_lo = TrustBandsamoroChristUnfair - 1.96*TrustBandsamoroChristUnfair_sd

gen TrustIOChristUnfair_hi = TrustIOChristUnfair + 1.96*TrustIOChristUnfair_sd
gen TrustIOChristUnfair_lo = TrustIOChristUnfair - 1.96*TrustIOChristUnfair_sd


gen TrustMILKChristFair_hi = TrustMILKChristFair + 1.96*TrustMILKChristFair_sd
gen TrustMILKChristFair_lo = TrustMILKChristFair - 1.96*TrustMILKChristFair_sd

gen TrustEthMILKChristFair_hi = TrustEthMILKChristFair + 1.96*TrustEthMILKChristFair_sd
gen TrustEthMILKChristFair_lo = TrustEthMILKChristFair - 1.96*TrustEthMILKChristFair_sd

gen TrustNatGovChristFair_hi = TrustNatGovChristFair + 1.96*TrustNatGovChristFair_sd
gen TrustNatGovChristFair_lo = TrustNatGovChristFair - 1.96*TrustNatGovChristFair_sd

gen TrustBandsamoroChristFair_hi = TrustBandsamoroChristFair + 1.96*TrustBandsamoroChristFair_sd
gen TrustBandsamoroChristFair_lo = TrustBandsamoroChristFair - 1.96*TrustBandsamoroChristFair_sd

gen TrustIOChristFair_hi = TrustIOChristFair + 1.96*TrustIOChristFair_sd
gen TrustIOChristFair_lo = TrustIOChristFair - 1.96*TrustIOChristFair_sd


graph set window fontface "Times New Roman"

gen axis_1 = 1
gen axis_2 = 2
gen axis_3 = 3
gen axis_4 = 4
gen axis_5 = 5

lab def JCRdotplot 1 "Nat. Gov." 2 "Bandsamoro Aut." 3 "MILF" 4 "Eth. MILF" 5 "IO aid"   
label val axis_1 JCRdotplot 

#delimit ;
twoway 

		(bar TrustNatGovChristUnfair axis_3, 
			color(black) barwidth(.35) msize(large))
		(rcap TrustNatGovChristUnfair_lo TrustNatGovChristUnfair_hi axis_3,
			lcolor(gs10))

	    (bar TrustBandsamoroChristUnfair axis_4, 
			color(black) barwidth(.35) msize(large))
		(rcap TrustBandsamoroChristUnfair_lo TrustBandsamoroChristUnfair_hi axis_4,
			lcolor(gs10))

		(bar TrustMILKChristUnfair axis_1, 
			color(black) barwidth(.35) msize(large))
		(rcap TrustMILKChristUnfair_lo TrustMILKChristUnfair_hi axis_1,
			lcolor(gs10))
						
		(bar TrustEthMILKChristUnfair axis_2, 
			color(black) barwidth(.35) msize(large))
		(rcap TrustEthMILKChristUnfair_lo TrustEthMILKChristUnfair_hi axis_2,
			lcolor(gs10))	
			
		(bar TrustIOChristUnfair axis_5, 
			color(black) barwidth(.35) msize(large))
		(rcap TrustIOChristUnfair_lo TrustIOChristUnfair_hi axis_5,
			lcolor(gs10))	
		,
legend(off)
ylabel(0(.2)1)
title("Muslim", size(medsmall))
xlabel(1 "Military" 2 "Political" 3 "Economic" 4 "Territorial" 5 "IO aid")
ytitle("Probability of Increasing Trust")
 xsize(7) ysize(5.5) 
name(GPH1, replace) 
scheme(s1mono)
;
#delimit cr



#delimit ;
twoway 

		(bar TrustNatGovChristFair axis_3, 
			color(black) barwidth(.35) msize(large))
		(rcap TrustNatGovChristFair_lo TrustNatGovChristFair_hi axis_3,
			lcolor(gs10))

	    (bar TrustBandsamoroChristFair axis_4, 
			color(black) barwidth(.35) msize(large))
		(rcap TrustBandsamoroChristFair_lo TrustBandsamoroChristFair_hi axis_4,
			lcolor(gs10))

		(bar TrustMILKChristFair axis_1, 
			color(black) barwidth(.35) msize(large))
		(rcap TrustMILKChristFair_lo TrustMILKChristFair_hi axis_1,
			lcolor(gs10))
						
		(bar TrustEthMILKChristFair axis_2, 
			color(black) barwidth(.35) msize(large))
		(rcap TrustEthMILKChristFair_lo TrustEthMILKChristFair_hi axis_2,
			lcolor(gs10))	
		
		(bar TrustIOChristFair axis_5, 
			color(black) barwidth(.35) msize(large))
		(rcap TrustIOChristFair_lo TrustIOChristFair_hi axis_5,
			lcolor(gs10))
		,
legend(off)
ylabel(0(.2)1)
title("Christian", size(medsmall))
ytitle("Probability of Increasing Trust")
xlabel(1 "Military" 2 "Political" 3 "Economic" 4 "Territorial" 5 "IO Aid")
xsize(7) ysize(5.5) 
name(GPH2, replace) 
scheme(s1mono)
;
#delimit cr



*Figure 2
#delimit ;	
graph combine GPH1 GPH2, rows(1) title("Figure 2: Effects of powersharing arrangement treatments on trust in the national government" 
"by religion with 95% CIs", size(small))
note("Dependent variable: Changing Trust in Gov.: The arrangement decreases trust(1), No effect(2), Increases trust(3)." "Data source: Philippines Powersharing Survey", size(small)) scheme(s1mono)
;
#delimit cr


